\(\int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx\) [274]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 87 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\frac {a^2 \log (\cos (c+d x))}{d}-\frac {2 a b \sec (c+d x)}{d}+\frac {\left (a^2-b^2\right ) \sec ^2(c+d x)}{2 d}+\frac {2 a b \sec ^3(c+d x)}{3 d}+\frac {b^2 \sec ^4(c+d x)}{4 d} \]

[Out]

a^2*ln(cos(d*x+c))/d-2*a*b*sec(d*x+c)/d+1/2*(a^2-b^2)*sec(d*x+c)^2/d+2/3*a*b*sec(d*x+c)^3/d+1/4*b^2*sec(d*x+c)
^4/d

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.095, Rules used = {3970, 908} \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\frac {\left (a^2-b^2\right ) \sec ^2(c+d x)}{2 d}+\frac {a^2 \log (\cos (c+d x))}{d}+\frac {2 a b \sec ^3(c+d x)}{3 d}-\frac {2 a b \sec (c+d x)}{d}+\frac {b^2 \sec ^4(c+d x)}{4 d} \]

[In]

Int[(a + b*Sec[c + d*x])^2*Tan[c + d*x]^3,x]

[Out]

(a^2*Log[Cos[c + d*x]])/d - (2*a*b*Sec[c + d*x])/d + ((a^2 - b^2)*Sec[c + d*x]^2)/(2*d) + (2*a*b*Sec[c + d*x]^
3)/(3*d) + (b^2*Sec[c + d*x]^4)/(4*d)

Rule 908

Int[((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIn
tegrand[(d + e*x)^m*(f + g*x)^n*(a + c*x^2)^p, x], x] /; FreeQ[{a, c, d, e, f, g}, x] && NeQ[e*f - d*g, 0] &&
NeQ[c*d^2 + a*e^2, 0] && IntegerQ[p] && ((EqQ[p, 1] && IntegersQ[m, n]) || (ILtQ[m, 0] && ILtQ[n, 0]))

Rule 3970

Int[cot[(c_.) + (d_.)*(x_)]^(m_.)*(csc[(c_.) + (d_.)*(x_)]*(b_.) + (a_))^(n_), x_Symbol] :> Dist[-(-1)^((m - 1
)/2)/(d*b^(m - 1)), Subst[Int[(b^2 - x^2)^((m - 1)/2)*((a + x)^n/x), x], x, b*Csc[c + d*x]], x] /; FreeQ[{a, b
, c, d, n}, x] && IntegerQ[(m - 1)/2] && NeQ[a^2 - b^2, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {\text {Subst}\left (\int \frac {(a+x)^2 \left (b^2-x^2\right )}{x} \, dx,x,b \sec (c+d x)\right )}{b^2 d} \\ & = -\frac {\text {Subst}\left (\int \left (2 a b^2+\frac {a^2 b^2}{x}-\left (a^2-b^2\right ) x-2 a x^2-x^3\right ) \, dx,x,b \sec (c+d x)\right )}{b^2 d} \\ & = \frac {a^2 \log (\cos (c+d x))}{d}-\frac {2 a b \sec (c+d x)}{d}+\frac {\left (a^2-b^2\right ) \sec ^2(c+d x)}{2 d}+\frac {2 a b \sec ^3(c+d x)}{3 d}+\frac {b^2 \sec ^4(c+d x)}{4 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.38 (sec) , antiderivative size = 74, normalized size of antiderivative = 0.85 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\frac {12 a^2 \log (\cos (c+d x))-24 a b \sec (c+d x)+6 \left (a^2-b^2\right ) \sec ^2(c+d x)+8 a b \sec ^3(c+d x)+3 b^2 \sec ^4(c+d x)}{12 d} \]

[In]

Integrate[(a + b*Sec[c + d*x])^2*Tan[c + d*x]^3,x]

[Out]

(12*a^2*Log[Cos[c + d*x]] - 24*a*b*Sec[c + d*x] + 6*(a^2 - b^2)*Sec[c + d*x]^2 + 8*a*b*Sec[c + d*x]^3 + 3*b^2*
Sec[c + d*x]^4)/(12*d)

Maple [A] (verified)

Time = 1.51 (sec) , antiderivative size = 75, normalized size of antiderivative = 0.86

method result size
parts \(\frac {a^{2} \left (\frac {\tan \left (d x +c \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}+\frac {b^{2} \tan \left (d x +c \right )^{4}}{4 d}+\frac {2 a b \left (\frac {\sec \left (d x +c \right )^{3}}{3}-\sec \left (d x +c \right )\right )}{d}\) \(75\)
derivativedivides \(\frac {\frac {b^{2} \sec \left (d x +c \right )^{4}}{4}+\frac {2 a b \sec \left (d x +c \right )^{3}}{3}+\frac {a^{2} \sec \left (d x +c \right )^{2}}{2}-\frac {\sec \left (d x +c \right )^{2} b^{2}}{2}-2 a b \sec \left (d x +c \right )-a^{2} \ln \left (\sec \left (d x +c \right )\right )}{d}\) \(79\)
default \(\frac {\frac {b^{2} \sec \left (d x +c \right )^{4}}{4}+\frac {2 a b \sec \left (d x +c \right )^{3}}{3}+\frac {a^{2} \sec \left (d x +c \right )^{2}}{2}-\frac {\sec \left (d x +c \right )^{2} b^{2}}{2}-2 a b \sec \left (d x +c \right )-a^{2} \ln \left (\sec \left (d x +c \right )\right )}{d}\) \(79\)
risch \(-i a^{2} x -\frac {2 i a^{2} c}{d}-\frac {2 \left (6 a b \,{\mathrm e}^{7 i \left (d x +c \right )}-3 a^{2} {\mathrm e}^{6 i \left (d x +c \right )}+3 b^{2} {\mathrm e}^{6 i \left (d x +c \right )}+10 a b \,{\mathrm e}^{5 i \left (d x +c \right )}-6 a^{2} {\mathrm e}^{4 i \left (d x +c \right )}+10 a b \,{\mathrm e}^{3 i \left (d x +c \right )}-3 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}+3 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+6 a b \,{\mathrm e}^{i \left (d x +c \right )}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(179\)

[In]

int((a+b*sec(d*x+c))^2*tan(d*x+c)^3,x,method=_RETURNVERBOSE)

[Out]

a^2/d*(1/2*tan(d*x+c)^2-1/2*ln(1+tan(d*x+c)^2))+1/4*b^2*tan(d*x+c)^4/d+2*a*b/d*(1/3*sec(d*x+c)^3-sec(d*x+c))

Fricas [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.94 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\frac {12 \, a^{2} \cos \left (d x + c\right )^{4} \log \left (-\cos \left (d x + c\right )\right ) - 24 \, a b \cos \left (d x + c\right )^{3} + 8 \, a b \cos \left (d x + c\right ) + 6 \, {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, b^{2}}{12 \, d \cos \left (d x + c\right )^{4}} \]

[In]

integrate((a+b*sec(d*x+c))^2*tan(d*x+c)^3,x, algorithm="fricas")

[Out]

1/12*(12*a^2*cos(d*x + c)^4*log(-cos(d*x + c)) - 24*a*b*cos(d*x + c)^3 + 8*a*b*cos(d*x + c) + 6*(a^2 - b^2)*co
s(d*x + c)^2 + 3*b^2)/(d*cos(d*x + c)^4)

Sympy [A] (verification not implemented)

Time = 0.27 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.45 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\begin {cases} - \frac {a^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {a^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} + \frac {2 a b \tan ^{2}{\left (c + d x \right )} \sec {\left (c + d x \right )}}{3 d} - \frac {4 a b \sec {\left (c + d x \right )}}{3 d} + \frac {b^{2} \tan ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}}{4 d} - \frac {b^{2} \sec ^{2}{\left (c + d x \right )}}{4 d} & \text {for}\: d \neq 0 \\x \left (a + b \sec {\left (c \right )}\right )^{2} \tan ^{3}{\left (c \right )} & \text {otherwise} \end {cases} \]

[In]

integrate((a+b*sec(d*x+c))**2*tan(d*x+c)**3,x)

[Out]

Piecewise((-a**2*log(tan(c + d*x)**2 + 1)/(2*d) + a**2*tan(c + d*x)**2/(2*d) + 2*a*b*tan(c + d*x)**2*sec(c + d
*x)/(3*d) - 4*a*b*sec(c + d*x)/(3*d) + b**2*tan(c + d*x)**2*sec(c + d*x)**2/(4*d) - b**2*sec(c + d*x)**2/(4*d)
, Ne(d, 0)), (x*(a + b*sec(c))**2*tan(c)**3, True))

Maxima [A] (verification not implemented)

none

Time = 0.20 (sec) , antiderivative size = 75, normalized size of antiderivative = 0.86 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=\frac {12 \, a^{2} \log \left (\cos \left (d x + c\right )\right ) - \frac {24 \, a b \cos \left (d x + c\right )^{3} - 8 \, a b \cos \left (d x + c\right ) - 6 \, {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 3 \, b^{2}}{\cos \left (d x + c\right )^{4}}}{12 \, d} \]

[In]

integrate((a+b*sec(d*x+c))^2*tan(d*x+c)^3,x, algorithm="maxima")

[Out]

1/12*(12*a^2*log(cos(d*x + c)) - (24*a*b*cos(d*x + c)^3 - 8*a*b*cos(d*x + c) - 6*(a^2 - b^2)*cos(d*x + c)^2 -
3*b^2)/cos(d*x + c)^4)/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 267 vs. \(2 (81) = 162\).

Time = 0.74 (sec) , antiderivative size = 267, normalized size of antiderivative = 3.07 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=-\frac {12 \, a^{2} \log \left ({\left | -\frac {\cos \left (d x + c\right ) - 1}{\cos \left (d x + c\right ) + 1} + 1 \right |}\right ) - 12 \, a^{2} \log \left ({\left | -\frac {\cos \left (d x + c\right ) - 1}{\cos \left (d x + c\right ) + 1} - 1 \right |}\right ) + \frac {25 \, a^{2} + 32 \, a b + \frac {124 \, a^{2} {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1} + \frac {128 \, a b {\left (\cos \left (d x + c\right ) - 1\right )}}{\cos \left (d x + c\right ) + 1} + \frac {198 \, a^{2} {\left (\cos \left (d x + c\right ) - 1\right )}^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}} + \frac {96 \, a b {\left (\cos \left (d x + c\right ) - 1\right )}^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}} - \frac {48 \, b^{2} {\left (\cos \left (d x + c\right ) - 1\right )}^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}} + \frac {124 \, a^{2} {\left (\cos \left (d x + c\right ) - 1\right )}^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}} + \frac {25 \, a^{2} {\left (\cos \left (d x + c\right ) - 1\right )}^{4}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{4}}}{{\left (\frac {\cos \left (d x + c\right ) - 1}{\cos \left (d x + c\right ) + 1} + 1\right )}^{4}}}{12 \, d} \]

[In]

integrate((a+b*sec(d*x+c))^2*tan(d*x+c)^3,x, algorithm="giac")

[Out]

-1/12*(12*a^2*log(abs(-(cos(d*x + c) - 1)/(cos(d*x + c) + 1) + 1)) - 12*a^2*log(abs(-(cos(d*x + c) - 1)/(cos(d
*x + c) + 1) - 1)) + (25*a^2 + 32*a*b + 124*a^2*(cos(d*x + c) - 1)/(cos(d*x + c) + 1) + 128*a*b*(cos(d*x + c)
- 1)/(cos(d*x + c) + 1) + 198*a^2*(cos(d*x + c) - 1)^2/(cos(d*x + c) + 1)^2 + 96*a*b*(cos(d*x + c) - 1)^2/(cos
(d*x + c) + 1)^2 - 48*b^2*(cos(d*x + c) - 1)^2/(cos(d*x + c) + 1)^2 + 124*a^2*(cos(d*x + c) - 1)^3/(cos(d*x +
c) + 1)^3 + 25*a^2*(cos(d*x + c) - 1)^4/(cos(d*x + c) + 1)^4)/((cos(d*x + c) - 1)/(cos(d*x + c) + 1) + 1)^4)/d

Mupad [B] (verification not implemented)

Time = 16.45 (sec) , antiderivative size = 151, normalized size of antiderivative = 1.74 \[ \int (a+b \sec (c+d x))^2 \tan ^3(c+d x) \, dx=-\frac {\frac {8\,a\,b}{3}-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (2\,a^2+\frac {32\,b\,a}{3}\right )-2\,a^2\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\,\left (4\,a^2+8\,a\,b-4\,b^2\right )}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+6\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}-\frac {2\,a^2\,\mathrm {atanh}\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\right )}{d} \]

[In]

int(tan(c + d*x)^3*(a + b/cos(c + d*x))^2,x)

[Out]

- ((8*a*b)/3 - tan(c/2 + (d*x)/2)^2*((32*a*b)/3 + 2*a^2) - 2*a^2*tan(c/2 + (d*x)/2)^6 + tan(c/2 + (d*x)/2)^4*(
8*a*b + 4*a^2 - 4*b^2))/(d*(6*tan(c/2 + (d*x)/2)^4 - 4*tan(c/2 + (d*x)/2)^2 - 4*tan(c/2 + (d*x)/2)^6 + tan(c/2
 + (d*x)/2)^8 + 1)) - (2*a^2*atanh(tan(c/2 + (d*x)/2)^2))/d